use crate::dao::fiof::FifoSDao;
use mongodb::{bson::doc, options::IndexOptions, Client, Collection, IndexModel};
use sqlx::mysql::MySqlPoolOptions;
use std::sync::Arc;

pub struct Seq {
    pub fiof_dao: Arc<FifoSDao>,
}

impl Seq {
    pub async fn new(mysql_uri: &str, mongo_uri: &str) -> Seq {
        let pool = MySqlPoolOptions::new()
            .max_connections(8)
            .connect(mysql_uri)
            .await
            .unwrap();
        let pool = Arc::new(pool);

        let client = Client::with_uri_str(mongo_uri)
            .await
            .expect("连接 mongo 失败");

        Seq {
            fiof_dao: Arc::from(FifoSDao::new(pool.clone(), client.clone())),
        }
    }
}
